// 根据角色动态生成路由
import { defineFakeRoute } from "vite-plugin-fake-server/client";
import { faker } from "@faker-js/faker";
function numList(min=1,max=100) {
  const names = [];
  for (let i = 0; i < 10; i++) {
    names.push(faker.number.int({ min: min, max: max}))
  }
  return names
}
function titleList() {
  let names=[]
   for (let i = 0; i < 10; i++) {
    names.push(faker.helpers.arrayElement(['政府','基金会','社会组织', '慈善信托', '企业', '个人', '其他']))
   }
  return names
}
export default defineFakeRoute([
  {
    url: "/barLine",
    method: "get",
    response: () => {
       return {
          success: true,
          data: {
            bar: [
              numList(),
              numList(1,20),
              numList(1,60)
            ],
            titleList:titleList(),
            line: numList(100000, 1000000),
            times:['2023-05','2023-06', '2023-07', '2023-08', '2023-09', '2023-10', '2023-11', '2023-12','2024-01','2024-02']
          }
        };
    }
  }, {
    url: "/barLineTwo",
    method: "get",
    response: () => {
      let num1 = numList(1000, 10000);
      let num2 =num1.map((item)=>item+faker.number.int(2000))
      return {
        success: true,
        data: {
          line: [
            numList(100, 1000),
            numList(1000, 15000),
          ],
          bar: [
            num1,
            num2
          ],
          times:['杭州青青草公益服务中心 ','杭州青青草公益服务中心 ', '2023-07', '2023-08', '2023-09', '2023-10', '2023-11', '2023-12','2024-01','2024-02']
          
        }
      }

    }
  }, {
    url: "/getsubLine",
    method: "get",
    response: () => {
      return {
        success: true,
        data: {
          line: numList(1000, 10000),
          times:['2023-05','2023-06', '2023-07', '2023-08', '2023-09', '2023-10', '2023-11']
        }
      }
    }
  }
])